package uiLayer;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;


public class SaveToFile {
	private static SaveToFile instance;
	public static SaveToFile getInstance()       
	{
		if(instance == null)
		{
			instance = new SaveToFile();
		}
		return instance;
	}
	public void clearFile(){
		File file = new File("file.txt");
		file.delete();
		file = new File("file.txt");
		try {
			file.createNewFile();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	public void save(String toSave) throws IOException{
			try {
				
				BufferedWriter bw = new BufferedWriter(new FileWriter("file.txt",true));
				bw.newLine();
				bw.write(toSave);
				bw.close();
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
			
		}
	}

